<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>继承-原型和借用构造器组合</title>
</head>
<body>

</body>

<script>

    function SuperType() { /*父类别*/
        this.name = "L";
        this.colors = ["white"]; // 引用类型
    }

    SuperType.prototype.sayHello=function () {
        alert("hello " + this.name);
    }

    function SubType() { /*子类别*/
        SuperType.call(this); // 借用构造器 --- 实例生成/函数触发时
    }

    SubType.prototype = new SuperType();

    var sub1 = new SubType();
    var sub2 = new SubType();


    sub1.name = "Martin";

    sub1.sayHello();

    sub2.sayHello();


</script>
</html>